package com.whale.widget;

import android.app.Activity;
import android.content.Context;
import android.text.TextPaint;
import android.view.View;
import android.widget.TextView;

import com.whale.R;

public class Header {

	public static final int CHOOSE_CIRCLE_AND_PEOPLE = 1;
	public static final int WRITE_FEED = 2;
	public static final int NORMAL = 3;

	private TextView mTitleButton;//头部标题
	private TextView mConfirmButton;//确认按钮
	private TextView mPostFeedButton;//发送按钮

	public Header(int style, Context context) {
		initHeader(style, (Activity) context);
	}

	private void initHeader(int style, final Activity activity) {
		switch (style) {
		case CHOOSE_CIRCLE_AND_PEOPLE:
			initTitle(activity);
			initConfirmButton(activity);
			break;
		case WRITE_FEED:
			initTitle(activity);
			initPostFeedButton(activity);
			break;
		case NORMAL:
			initTitle(activity);
		}
	}

	/**
	 * 初始化头部的标题
	 * 
	 * @param acticity
	 */
	private void initTitle(final Activity activity) {
		mTitleButton = (TextView) activity.findViewById(R.id.title);
	}

	/**
	 * 初始化确认按钮
	 * 
	 * @param activity
	 */
	private void initConfirmButton(final Activity activity) {
		mConfirmButton = (TextView) activity
				.findViewById(R.id.confirm_or_send_button);
		mConfirmButton.setText(R.string.confirm);
		mConfirmButton.setVisibility(View.VISIBLE);
	}

	/**
	 * 初始化发送按钮
	 * 
	 * @param activity
	 */
	private void initPostFeedButton(final Activity activity) {
		mPostFeedButton = (TextView) activity
				.findViewById(R.id.confirm_or_send_button);
		mPostFeedButton.setText(R.string.bt_send);
		mPostFeedButton.setVisibility(View.VISIBLE);
	}

	/**
	 * 设置标题
	 * 
	 * @param title
	 */
	public void setHeaderTitle(String title) {
		if (null != mTitleButton) {
			mTitleButton.setText(title);
			TextPaint tp = mTitleButton.getPaint();
			tp.setFakeBoldText(true);
		}
	}

	public void destroy() {
		mTitleButton = null;
	}
}
